#ifndef C0_BUILDSYM_H
#define C0_BUILDSYM_H

#include "ast.h"
#include <iostream>

using namespace std;
const int symMax = 100;
extern int gvNum;
extern int lvNum;
extern int fNum;

class BuildSym : public ast::Visitor {
public:
    char *name{};//名字
    char *kind{};//
    char *typeGLF{};//
    char *scope{};//作用域
    int size = 2;//大小
    int level{};//层次
    int adr{};//地址
    int location{};
    int blockList{};
    bool hasBeenCalled{};//在当前函数是否被调用过
    bool hasBeenUsed{};//变量是否使用过

    BuildSym() = default;

    [[maybe_unused]] static void showSym();

    explicit BuildSym(past node) : node(node) {}

    void visit(VarDef *) override;

    void visit(FuncDef *) override;

    void visit(UnaryExp *) override;

    void visit(Block_list *) override;

    void visit(CompUnit *) override {};

    void visit(Decl *) override {};

    void visit(expr *) override {};

    void visit(parameter *) override {};

    void visit(Assign_Stmt *) override {};

    void visit(FuncDef_para *) override {};

    void visit(Return_Stmt *) override {};

    void visit(VarDecl_list *) override {};

    void visit(FuncRParams_list *) override {};

    void visit(type *) override {};

    void visit(intValue *) override {};

    void visit(VarDecl *) override;

    void visit(IfElse_Stmt *) override{};

    void visit(If_Else *) override{};

    void visit(While_Stmt *) override{};

private:
    past node{};
};

extern BuildSym gv[symMax];

extern BuildSym lv[symMax];

extern BuildSym func[symMax];

#endif //C0_BUILDSYM_H
